package dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import pojo.Attention;
import pojo.Page;

public interface AttentionDao {

	@Select(value="select user2_id from attention where user1_id=#{userId} limit #{page.currentPage},#{page.limitNumber}")
	@Results({
		@Result(column="user2_id", property="user2Id")
	})
	public List<Integer> SelectByUserId(@Param("userId") Integer userId, @Param("page") Page page);

	@Select(value="select count(*) from attention where user1_id=#{userId} ")
	public Integer SelectByUserIdCount(@Param("userId") Integer userId);


	@Select(value="select count(*) from attention where user1_id=#{user1Id} and user2_id=#{user2Id}")
	public int selectAttentionOrNot(@Param("user1Id")Integer user1Id,@Param("user2Id")Integer user2Id);
	
	@Update(value="update attention set ltof=#{ltof} where user1_id=#{user1Id} and user2_id=#{user2Id}")
	public int updateAttention(@Param("user1Id")Integer user1Id,@Param("user2Id")Integer user2Id,@Param("ltof") Integer ltof);
	
	@Select(value="select * from attention where user1_id=#{user1Id} and user2_id=#{user2Id}")
	@Results({
		@Result(column="attention_id",property="attentionId",id=true),
		@Result(column="user1_id",property="user1Id"),
		@Result(column="user2_id",property="user2Id")
	})
	public Attention selectByUser(@Param("user1Id")Integer user1Id,@Param("user2Id")Integer user2Id);
}
